package com.mofang.powerdekorhelper.activity.customer;

import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;

import com.mofang.powerdekorhelper.R;
import com.mofang.powerdekorhelper.adapter.ChooseActivityListAdapter;
import com.mofang.powerdekorhelper.base.BaseActivity;
import com.mofang.powerdekorhelper.base.recycleview.BaseRecycleViewAdapter;
import com.mofang.powerdekorhelper.base.recycleview.BaseRecycleViewList;
import com.mofang.powerdekorhelper.model.CustomerActivity;
import com.mofang.powerdekorhelper.utils.LoadPrograss;
import com.mofang.powerdekorhelper.utils.SharePerforenceUtils;
import com.mofang.powerdekorhelper.witget.TitleBar;

import butterknife.BindView;

/**
 * Created by luofei on 2017/8/23 0023.
 */

public class ChooseActivityListAct extends BaseActivity {

    @BindView(R.id.activity_list_titlebar)
    TitleBar mTitleBar;

    @BindView(R.id.activity_list)
    BaseRecycleViewList activityRecycle;

    private LoadPrograss loadPrograss;
    private int page = 1;
    private int pageSize = 10;
    ChooseActivityListAdapter adapter;

    private CustomerActivity customerActivity;

    @Override
    public void initView() {
        inflateLayout(R.layout.fragment_activity_layout);
        initTitleBar2(mTitleBar, R.string.activity_list);
        loadPrograss = new LoadPrograss(this);
    }

    @Override
    public void initData() {
        customerActivity = (CustomerActivity) getIntent().getSerializableExtra("CustomerActivity");
        adapter = new ChooseActivityListAdapter(customerActivity.getResult(), this, R.layout.activity_list_item_layout);
        adapter.setOnItemClickListner(new BaseRecycleViewAdapter.OnItemClickListner() {
            @Override
            public void onItemClickListner(ViewGroup parent, View v, int position) {
                CustomerActivity.Result result = (CustomerActivity.Result) v.getTag();
                Intent intent = new Intent();
                intent.putExtra("ActivityId", result.getActivity_id());
                setResult(RESULT_OK,intent);
                finish();
            }
        });
        activityRecycle.setAdapter(adapter);
    }
}
